package com.ecar.api.service.common.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ecar.api.service.common.ActivityService;
import com.ecar.core.common.dao.CouponActivitiesMapper;
import com.ecar.core.common.dao.CouponMapper;
import com.ecar.core.common.entity.Coupon;
import com.ecar.core.common.entity.CouponActivities;
@Service
@Transactional
public class ActivityServiceImpl implements ActivityService{

	@Autowired
	public CouponActivitiesMapper couponActivitiesMapper;
	
	@Autowired
	public CouponMapper couponMapper;
	
	@Override
	public List<CouponActivities> queryCouponActivities() {
		return couponActivitiesMapper.selectAll();
	}

	@Override
	public boolean pullCoupon(Coupon coupon) {
		boolean flag=false;
		if(couponMapper.insert(coupon)>0) flag=true;
		return flag;
	}

	@Override
	public List<Coupon> selectNotUsedCoupon() {
		return couponMapper.selectNotUsedCoupon();
	}

	@Override
	public int updateByPrimaryKey(Coupon record) {
		return couponMapper.updateByPrimaryKey(record);
	}

	@Override
	public Coupon selectByCouponActIdAndUserId(String couponId, String userId) {
		return couponMapper.selectByCouponActIdAndUserId(couponId, userId);
	}

	@Override
	public List<CouponActivities> selectCouponByUserId(String passengerId) {
		return couponMapper.selectCouponByUserId(passengerId);
	}

	@Override
	public List<Coupon> selectByUserId(String passengerId) {
		return couponMapper.selectByUserId(passengerId);
	}

	@Override
	public CouponActivities selectByPrimaryKey(String id) {
		return couponActivitiesMapper.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(Coupon record) {
		
		return couponMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(CouponActivities record) {
		return couponActivitiesMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateCouponCountByActivityId(String couponActivityId,
			int couponCount) {
		return couponActivitiesMapper.updateCouponCountByActivityId(couponActivityId, couponCount);
	}

}
